package com.nageoffer.jobtrain.projects.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.nageoffer.jobtrain.common.web.result.Result;
import com.nageoffer.jobtrain.common.web.result.Results;
import com.nageoffer.jobtrain.projects.dto.req.*;
import com.nageoffer.jobtrain.projects.dto.resp.*;
import com.nageoffer.jobtrain.projects.service.ContestService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 竞赛接口控制层
 * author：唐晨
 */
@RestController
@RequiredArgsConstructor
public class ContestController {
    private final ContestService contestService;

    /**
     * 竞赛分页请求-开始结束时间/标题
     */
    @PostMapping("/api/job-train/project/contest/page")
    public Result<IPage<ContestPageRespDTO>> contestPageList(@RequestBody ContestPageReqDTO requestParam) {
        return Results.success(contestService.contestPageList(requestParam));
    }

    /**
     * 竞赛预约提醒功能
     */
    @PostMapping("/api/job-train/project/contest/remind")
    public Result<Void> createRemindContest(@RequestBody ContestCreateRemindReqDTO requestParam) {
        contestService.createRemindContest(requestParam);
        return Results.success();
    }

    /**
     * 竞赛取消预约提醒功能
     */
    @PostMapping("/api/job-train/project/contest/cancel-remind")
    public Result<Void> cancelRemindContest(@RequestBody ContestRemindCancelReqDTO requestParam) {
        contestService.cancelRemindContest(requestParam);
        return Results.success();
    }

    /**
     * 查询用户预约某个竞赛信息详情
     */
    @PostMapping("/api/job-train/project/contest/some-remind")
    public Result<ContestRemindQueryRespDTO> someRemindContest(@RequestBody SomeRemindContestReqDTO requestParam) {
        return Results.success(contestService.someRemindContest(requestParam));
    }

    /**
     * 查询某个竞赛中的第一道OJ题目ID
     */
    @GetMapping("/api/job-train/project/contest/first-question")
    public Result<ContestFirstQuestionRespDTO> firstQuestionContest(@RequestParam("id") Long id) {
        return Results.success(contestService.firstQuestionContest(id));
    }

    /**
     * 获取某个竞赛上一道OJ题目ID
     */
    @PostMapping("/api/job-train/project/contest/prev-question")
    public Result<ContestPrevQuestionRespDTO> prevQuestionContest(@RequestBody ContestPrevQuestionReqDTO requestParam) {
        return Results.success(contestService.prevQuestionContest(requestParam));
    }

    /**
     * 获取某个竞赛下一道OJ题目ID
     */
    @PostMapping("/api/job-train/project/contest/next-question")
    public Result<ContestNextQuestionRespDTO> nextQuestionContest(@RequestBody ContestNextQuestionReqDTO requestParam) {
        return Results.success(contestService.nextQuestionContest(requestParam));
    }
}